package com.powernode.shop.thread;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author ZHAOZHENYU
 * @since 2022/10/11
 */
public class ManagerThreadPool {
    public static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
            4,      //核心线程数
            Runtime.getRuntime().availableProcessors(), //最大线程数
            30,     //空闲线程的存活时间
            TimeUnit.SECONDS,   //keepAliveTime的单位
            new LinkedBlockingDeque<>(30),   //任务队列
            Executors.defaultThreadFactory(),   //线程工厂，用来创建线程
            new ThreadPoolExecutor.AbortPolicy()     //拒绝策略，默认是AbortPolicy，会抛出异常
    );
}
